package com.nbjtjc.safe.api.sys;

import com.nbjtjc.common.validator.ValidatorUtils;
import com.nbjtjc.common.validator.group.DeleteGroup;
import com.nbjtjc.common.validator.group.UpdateGroup;
import com.nbjtjc.safe.bean.Result;
import com.nbjtjc.safe.model.sys.SysDutyType;
import com.nbjtjc.safe.service.sys.SysDutyTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @auther guqianbin
 * @date 2018/8/21 16:51
 * 值班类型
 **/
@RestController
@CrossOrigin("*")
@RequestMapping("/sysDutyType")
public class SysDutyTypeController {

    @Autowired
    private SysDutyTypeService sysDutyTypeService;

    @PostMapping("/find")
    public Result find(SysDutyType sysDutyType){
        Result result=new Result();
        result.setData(sysDutyTypeService.find(sysDutyType));
        return result;
    }

    @PostMapping("/add")
    public Result add(SysDutyType sysDutyType){
        ValidatorUtils.validateEntity(sysDutyType);
        Result result=new Result();
        result=sysDutyTypeService.add(sysDutyType);
        result.setData(sysDutyType);
        return result;
    }

    @PostMapping("/delete")
    public Result delete(SysDutyType sysDutyType){
        ValidatorUtils.validateEntity(sysDutyType, DeleteGroup.class);
        Result result=new Result();
        sysDutyTypeService.delete(sysDutyType);
        return result;
    }

    @PostMapping("/update")
    public Result update(SysDutyType sysDutyType){
        ValidatorUtils.validateEntity(sysDutyType, UpdateGroup.class);
        Result result=new Result();
        sysDutyType=sysDutyTypeService.update(sysDutyType);
        result.setData(sysDutyType);
        return result;
    }
}
